package com.example.demo.controller;

import com.example.demo.bean.UpdateData;
import com.example.demo.service.UpdateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
public class UpdateController {
    @Autowired
    UpdateService us;

    @RequestMapping(value = "Update",method = RequestMethod.POST)
    public UpdateData simpleUpdate(HttpServletRequest request){
        UpdateData updateData=new UpdateData();
        Map<String,String[]> map=request.getParameterMap();
        if(us.simpleUpdate(map)){
            updateData.setCode(200);
            updateData.setMessage("Update success");
        }
        else{
            updateData.setCode(500);
            updateData.setMessage("Update Failed");
        }
        return updateData;
    }
}
